package com.eliza.cmps.activity

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.CompoundButton
import android.widget.Switch
import android.widget.ToggleButton
import com.eliza.cmps.R
import com.eliza.library.tools.InfoTools

class SwitchActivity : AppCompatActivity(), CompoundButton.OnCheckedChangeListener {

    private var context = this
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_switch)

        findViewById<ToggleButton>(R.id.tbtn_open).setOnCheckedChangeListener(this)
        findViewById<Switch>(R.id.swh_status).setOnCheckedChangeListener(this)
    }

    override fun onCheckedChanged(compoundButton: CompoundButton, p1: Boolean) {
        when (compoundButton.id) {
            R.id.tbtn_open ->
                if (compoundButton.isChecked) {
                    InfoTools.ToastTools(context, "打开声音");
                } else {
                    InfoTools.ToastTools(context, "关闭声音")

                }
            R.id.swh_status ->
                if (compoundButton.isChecked) {
                    InfoTools.ToastTools(context, "开关:ON")
                } else {
                    InfoTools.ToastTools(context, "开关:OFF")
                }
        }
    }
}